package weekMatch.one_346;

public class LeeCode_01 {
    public static void main(String[] args) {

    }
    private static int minLength(String s) {
        StringBuilder sb = new StringBuilder(s);
        while (sb.indexOf("AB") != -1 || sb.indexOf("CD") != -1){
            while (sb.indexOf("AB") != -1){
                sb.replace(sb.indexOf("AB"), sb.indexOf("AB") + 2, "");
            }
            while (sb.indexOf("CD") != -1){
                sb.replace(sb.indexOf("CD"), sb.indexOf("CD") + 2, "");
            }
        }
        return sb.length();
    }
}
